(function (lib, config) {
<<<<<<< .mine
    /*
    config = {
        dotname: '男科张医生',
        typeid: '1',
        words: '您好，有什么可以帮助的吗？',
        bgcolor: '#ab2626',
        textcolor: '#9e3636',
        imglink: '/upload/20180521/201805211045251799.png',
        weblink: '',
        flashid: '0',
        positionid: '5',
        firsttime: '10',
        relapsetime: '30',
        eachtime: '20',
        iscomapp: '1',
        identifier: 'centerswt'
    };
    */
=======
>>>>>>> .r143
    function getscrollTop() {
        var scrollTop = 0;
        if (document.documentElement && document.documentElement.scrollTop) {
            return document.documentElement.scrollTop;
        }
        if (document.body.scrollTop) {
            return document.body.scrollTop;
        }
    }
    function getClientHeight() {
        var clientHeight = 0;
        if (document.body.clientHeight && document.documentElement.clientHeight) {
            var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
        }
        else {
            var clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
        }
        return clientHeight;
    }

    var _ua = navigator.userAgent, _ua_text = false, _position = "fixed";
    if (config.iscomapp && _ua.indexOf('baiduboxapp') > -1) {
        _ua_text = true; _position = "absolute";
    }
    var loadFunc = function () {
        var htmlList = [], bgcolorAry = config.bgcolor.split('|'), textcolorAry = config.bgcolor.split('|'), wordAry = config.words.split('|'), imglinkAry = config.imglink.split('|'), wordDivTemplate = " <a href=\'javascript:void(0);\' onclick=\'openZoosUrl(\"{{identifier}}\")\' id=\'hycq_dhk{{index}}\' style=\'display:none;\'> <img src=\'{{imglink}}\'><p>{{str}}</p></a>";
        var dotname = wordAry[0]; wordAry.splice(0,1);
        htmlList.push("<style>");
        htmlList.push("@-webkit-keyframes marquee {");
        htmlList.push("    0% { left: 0; }");
        htmlList.push("    100% { left: -100%; }");
        htmlList.push("}");
        htmlList.push("@-moz-keyframes marquee {");
        htmlList.push("    0% { left: 0; }");
        htmlList.push("    100% { left: -100%; }");
        htmlList.push("}");
        htmlList.push("@-ms-keyframes marquee {");
        htmlList.push("    0% { left: 0; }");
        htmlList.push("    100% { left: -100%; }");
        htmlList.push("}");
        htmlList.push("@-o-keyframes marquee {");
        htmlList.push("    0% { left: 0; }");
        htmlList.push("    100% { left: -100%; }");
        htmlList.push("}");
        htmlList.push("@keyframes marquee {");
        htmlList.push("  0%{left:0}");
        htmlList.push("  100%{left: -100%}");
        htmlList.push("}");
        htmlList.push(".flagBox{position:fixed;z-index:99999999;top:0;width:100%;height:100%;-webkit-transition:all 8s ease;-o-transition:all 8s ease;transition:all 8s ease;overflow-y: auto; visibility:hidden;}");
        htmlList.push(".swt_fcenter{ width:100%;max-width: 640px; margin:0 auto; background:#f5f5f5;overflow: auto;position:fixed; right:0; left:0; top:0; bottom:0;  }");
        htmlList.push(".swtqp_div1{ width:100%; margin:0 auto;background:{{bgcolor}}; padding:1% 3%; font-size:26px; color:#fff; text-align:center;position: fixed;max-width: 640px;  z-index:99999;font-weight: bold;line-height: 40px;}");
        htmlList.push(".swtqp_div1 a{font-size:20px;color:{{textcolor}}; width:15%; float:left; margin-top:1%;line-height: 33px;}");
        htmlList.push(".swtqp_div1 a i{ width:35px; height:40px; float:left; background:url(http://nkm.6660333.cn/images/swt_dbtbs1.png) no-repeat 73% 0%; background-size:285% 100%; margin-right:6%;}");
        htmlList.push(".swtqp_div1 a:nth-child(2) i{ background-position:3% 0%;  background-size:285% 100%; }");
        htmlList.push(".swtqp_div1 a:nth-child(2){ width:9%; float:right;}");
        htmlList.push(".swtqp_div2{ width:100%; height:auto; overflow:hidden; margin:1% auto 0%; text-align:center;}");
        htmlList.push(".swtqp_div2 img:nth-child(2){ margin-top:6%;}");
        htmlList.push(".swtqp_div2 img{ width:100%;}");
        htmlList.push(".swtqp_div3s{ width: 100%; height: auto;overflow:hidden; margin-top:12.5%; background:#f3f3f3; padding:0 0% 0 4%;}");
        htmlList.push(".swtqp_div3s .scroll_gg{ padding:0;}");
        htmlList.push(".swtqp_div3s div{ padding:0 3%;height:40px;}");
        htmlList.push(".swtqp_div3s .scroll_gg1{ padding:2% 0;}");
        htmlList.push(".swtqp_div3s div:nth-child(2) div:nth-child(2){ padding:0;}");
        htmlList.push(".swtqp_div3s div{  font-size:22px; padding:0;color:#333333;margin: 0;font-weight:bold; }");
        htmlList.push(".swtqp_div3s h3{ width:100%; margin:0 auto; font-size:22px; font-weight:normal;font-weight:bold;color: #333333; padding-top: 1%; }");
        htmlList.push(".scroll_gg div{ line-height: 50px;}");
        htmlList.push(".swtqp_div3{ width:100%; height:auto; overflow:hidden;padding: 9% 4% 23%;}");
        htmlList.push(".swtqp_div3 a{ width:100%; float:left;}");
        htmlList.push(".swtqp_div3 a b{ color:#cc0000; font-weight:normal;}");
        htmlList.push(".swtqp_div3 a img{ float:left; margin-right:4%;width:22%;}");
        htmlList.push(".swtqp_div3 p{ width:70%; float:left; line-height:40px; font-size:24px; color:{{textcolor}}; position:relative; padding: 2% 3% 3% 3%;border-radius: 10px; border:1px solid #88d56d; background:#9de983; }");
        htmlList.push(".swtqp_div3 p:before{ content:\'\'; width:17px; height:29px;left:-3.5%; top:20%; background:url(http://nkm.6660333.cn/images/swt_qpsj.png) no-repeat; position: absolute; background-size:100%;}");
        htmlList.push(".swtqp_div3 a:nth-child(2){ margin-top:6%;}");
        htmlList.push(".marquee{ overflow: hidden;position: relative;} ");
        htmlList.push(".marquee div h3{display: block;width: 200%; position: absolute;overflow: hidden;  -webkit-animation: marquee 13s linear infinite; -moz-animation: marquee 13s linear infinite; -ms-animation: marquee 13s linear infinite;-o-animation: marquee 13s linear infinite;animation: marquee 13s linear infinite;}");
        htmlList.push(".swtqp_div4{ max-width: 640px; width:100%;height:auto; overflow:hidden; margin:2% auto 0%; position: " + _position + ";bottom: 0;}");
        htmlList.push(".swtqp_div4 a{width: 100%;text-align: center;display: block;}");
        htmlList.push(".swtqp_div4 a img{width: 100%;}");
        htmlList.push("@media screen and (max-width:638px) and (min-width:480px){");
        htmlList.push(".swtqp_div1 a{ font-size:16px;}");
        htmlList.push(".swtqp_div1 a i{ width:29px; height:33px; margin-right: 3%;}");
        htmlList.push(".swtqp_div1{ font-size:21px; padding: 2.5% 3%;line-height: 35px;}");
        htmlList.push(".swtqp_div3 p:before{left: -4.5%;}");
        htmlList.push(".swtqp_div3 p{ font-size:18px; line-height:33px;}");
        htmlList.push(".swtqp_div3 a img{ width:14%;}");
        htmlList.push(".swtqp_div3s h3{ padding-top: 2%;}");
        htmlList.push("}");
        htmlList.push("@media screen and (max-width: 479px) and (min-width: 319px){");
        htmlList.push(".swtqp_div1{ font-size:17px;line-height: 29px;}");
        htmlList.push(".swtqp_div1 a{width: 19%; font-size:14px;line-height: 24px;}");
        htmlList.push(".swtqp_div1 a i{ width:25px; height:28px;}");
        htmlList.push(".swtqp_div3s h3{font-size: 16px;}");
        htmlList.push(".scroll_gg div{ line-height: 35px;}");
        htmlList.push(".swtqp_div3s div{  height: 33px;}");
        htmlList.push(".swtqp_div3 a img{ width:14%;}");
        htmlList.push(".swtqp_div3 p,.swtqp_div3 a:nth-child(2) p{ font-size:12px; line-height:21px; }");
        htmlList.push(".swtqp_div3 p:before{ width:10px; height:15px; left: -4.0%;}");
        htmlList.push(".swtqp_div3{ padding:10% 4% 0%;}");
        htmlList.push(".swtqp_div3s h3{ padding-top: 2%;}");
        htmlList.push("}");
        htmlList.push("@media screen and (max-width:414px) and (min-width:380px){");
        htmlList.push(".swtqp_div3 p, .swtqp_div3 a:nth-child(2) p{ font-size:15px; line-height:30px;}");
        htmlList.push(".swtqp_div3 p:before{width: 12px;height: 18px; }");
        htmlList.push(".swtqp_div1 a{ width: 17%;font-size: 16px;}");
        htmlList.push(".swtqp_div1 a:nth-child(2){ width:7%;}");
        htmlList.push(".swtqp_div3s{margin-top: 11.0%;}");
        htmlList.push("}");
        htmlList.push("@media screen and (max-width:380px) and (min-width:360px){");
        htmlList.push(".swtqp_div3 p, .swtqp_div3 a:nth-child(2) p{font-size:13px; line-height:25px;}");
        htmlList.push(".swtqp_div3 p:before{width: 12px;height: 18px; }");
        htmlList.push(".swtqp_div1 a{width: 17.5%;font-size: 15px;}");
        htmlList.push(".swtqp_div1 a:nth-child(2){ width:7%;}");
        htmlList.push(".swtqp_div3s h3{ padding-top: 1.5%;}");
        htmlList.push("}");
        htmlList.push("</style>");
        htmlList.push("<div class=\'flagBox\' id=\'flagBox\'>");
        htmlList.push("  <div class=\'swt_fcenter\' id=\'swt_fcenter\'>");
        htmlList.push("    <div class=\'swtqp_div1\'> <a onclick=\'swt_center_nswt();\' id=\'aclose\'><i></i>返回</a> {{dotname}} <a href=\'tel:0734-8263333\'><i></i></a> </div>");
        htmlList.push("    <div class=\'swtqp_div3s\'>");
        htmlList.push("    <div class=\'marquee\'>");
        htmlList.push("            <div style=\'width:100%;overflow:hidden; white-space: nowrap;margin:0 auto; padding:0;\'>");
        htmlList.push("            <h3>衡阳卫生局唯一批准男科医院  北京协和医院专家指导医院 郭应禄院士领衔三甲男科专家团坐诊   衡阳卫生局唯一批准男科医院  北京协和医院专家指导医院 郭应禄院士领衔三甲男科专家团坐诊</h3>");
        htmlList.push("       </div>");
        htmlList.push(" </div>");
        htmlList.push(" </div>");
        htmlList.push("    <div class=\'swtqp_div2\' onClick=\'openZoosUrl(\"{{identifier}}\")\'> <img src=\'http://nkm.6660333.cn/images/new_qpswt1.jpg\'> </div>");
        htmlList.push("");
        htmlList.push("    <div class=\'swtqp_div3\'>");
        for (var i = 0; i < wordAry.length; i++) {
            htmlList.push(lib.util.resolveTemplate(wordDivTemplate, "imglink", imglinkAry[0], "str", wordAry[i], "index", i + 1));
        }
        htmlList.push("      </div>");
        htmlList.push("       <div class=\'swtqp_div4\' id=\'swtqp_div4\' style=\'bottom:0%;\'> <a href=\'javascript:void(0);\' onClick=\'openZoosUrl(\"{{identifier}}\")\'> <img src=\'http://nkm.6660333.cn/images/new_qpswt3.gif\' class=\'swtpb_t\'></a>");
        htmlList.push("      </div>");
        htmlList.push("</div>");
        htmlList.push("</div>");
        htmlList.push("");
        document.getElementsByTagName('body')[0].innerHTML += lib.util.resolveTemplate(htmlList.join(''), 'bgcolor', bgcolorAry[0], 'textcolor', textcolorAry[0], 'dotname', dotname, 'identifier', config.identifier)
        // 根据关键词列表生成a标签
        if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
            window.setTimeout(showDiv, 25000);
        }
        var _scrollset = 0;
        function showDiv() {
            document.getElementById('flagBox').style.visibility = 'visible';
            document.getElementById('flagBox').style.display = 'block';
            var index = 0;
            function showPro() {
                document.getElementById('hycq_dhk' + (index + 1)).style.display = 'block';
                if (++index > wordAry.length - 1) return;
                setTimeout(arguments.callee, 3000);
            }
            showPro();
            if (config.eachtime > 0) setTimeout(swt_center_nswt, config.eachtime * 1000);
            history.pushState({ lzjt: 1 }, "", "#com");
            _scrollset = 1;
        }
        setTimeout(showDiv, config.firsttime * 1000);
        window,swt_center_nswt=function() {
            document.getElementById('flagBox').style.display = 'none';
            document.getElementById('flagBox').style.visibility = 'hidden';
            for (var i = 0; i < wordAry.length; i++) document.getElementById('hycq_dhk' + (i + 1)).style.display = 'none';
            _scrollset = 0;
            if (config.relapsetime > 0) setTimeout(showDiv, config.relapsetime * 1000);
            history.replaceState(null, '', location.pathname + location.search);
        }
        lib.util.addEvent('hashchange', function () {
            swt_center_nswt();
        });

        // 调用方法
        (function () {
            var keyfun = function (a) {
                if (a == "" || a == null) { return ""; }
                var refer = a;
                var sosuo = refer.split(".")[1];
                var grep = null;
                var str = null;
                var keyword = null;
                switch (sosuo) {
                    case "baidu":
                        refer += '&';
                        grep = /word\=.*\&/i;
                        str = refer.match(grep);
                        if (str != null) {
                            keyword = str.toString().split("=")[1].split("&")[0];
                            return decodeURIComponent(keyword);
                        }
                        break;
                    case "sogou":
                        grep = /keyword\=.*\&/i;
                        str = refer.match(grep);
                        if (str != null) {
                            keyword = str.toString().split("=")[1].split("&")[0];
                            return decodeURIComponent(keyword);
                        }
                        break;
                    case "sm":
                    case "m":
                        if (refer.indexOf('sm') > -1) {
                            refer = refer.replace('?q=', '?&q=');
                            grep = /&q\=.*\&/i;
                            str = refer.match(grep);
                            if (str != null) {
                                keyword = str.toString().split("&")[1].split("=")[1];
                                return decodeURIComponent(keyword);
                            }
                        }
                        break;
                }
                return '';
            }
            var key_title_text = keyfun(r), key_fk_tjfs = '';

            if (swtqp_div3 != null) {
                if (key_title_text != '') {
                    swtqp_div3.innerHTML = '您是想了解【<b style="color: #bb1a1a;font-weight: bolder;">' + key_title_text + '</b>】的问题吗，具体情况可以跟我讲，我帮你详细分析';
                    key_fk_tjfs = encodeURIComponent('||key:' + key_title_text);
                }
            }

        })();
        if (_ua_text) {
            var _t_swtqp_div4 = document.getElementById('swtqp_div4').style.bottom;
            if (_t_swtqp_div4 == '') { _t_swtqp_div4 = 0; }
            lib.util.addEvent('scroll', function () {
                document.getElementById('swtqp_div4').style.bottom = parseInt(_t_swtqp_div4) - (getScrollTop() / getClientHeight()) * 100 + '%';

            })

        }
    };
    lib.load(loadFunc);
})('{{lib}}', '{{config}}');
